﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:Chapter10="clr-namespace:FSharp.Chapter10;assembly=FSharpLibrary">
	<Style x:Key="{ComponentResourceKey TypeInTargetAssembly=Chapter10:CustomChromeWindow, ResourceId=WindowButtonStyle}"
		   TargetType="Button">
		<Setter Property="Width"
				Value="30" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly=Chapter10:CustomChromeWindow, ResourceId=ButtonTemplate}"
								 TargetType="Button">
					<Grid>
						<Border>
							<Image x:Name="ButtonImage"
								   Source="{Binding Path=(Chapter10:CustomChromeWindow.NormalImage), RelativeSource={RelativeSource TemplatedParent}}"
								   Width="24"
								   Height="20"
								   Stretch="Fill" />
						</Border>
					</Grid>

					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver"
								 Value="True">
							<Setter Property="Source"
									TargetName="ButtonImage"
									Value="{Binding Path=(Chapter10:CustomChromeWindow.HoverImage), RelativeSource={RelativeSource TemplatedParent}}" />
						</Trigger>
						<Trigger Property="IsPressed"
								 Value="True">
							<Setter Property="Source"
									TargetName="ButtonImage"
									Value="{Binding Path=(Chapter10:CustomChromeWindow.PressedImage), RelativeSource={RelativeSource TemplatedParent}}" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<LinearGradientBrush x:Key="TitleBrush"
						 StartPoint="0,0"
						 EndPoint="0,1">
		<GradientStop Offset="0"
					  Color="#5FCCCCCC" />
		<GradientStop Offset="0.5"
					  Color="#5FCCCCCC" />
		<GradientStop Offset="0.5"
					  Color="Transparent" />
		<GradientStop Offset="1"
					  Color="Transparent" />
	</LinearGradientBrush>

	<ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly=Chapter10:CustomChromeWindow, ResourceId=WindowTemplate}"
					 TargetType="Chapter10:CustomChromeWindow">
		<Grid Background="Transparent">
			<Grid.RowDefinitions>
				<RowDefinition Height="32" />
				<RowDefinition Height="*" />
			</Grid.RowDefinitions>

			<Border Grid.Row="0"
					Grid.RowSpan="2"
					BorderBrush="Black"
					BorderThickness="1"
					CornerRadius="5">
				<Border BorderBrush="#0FFFFFFF"
						BorderThickness="1"
						CornerRadius="5"
						Background="#cF000000" />
			</Border>
			<DockPanel x:Name="PART_TitleBar"
					   Grid.Row="0"
					   Background="{StaticResource TitleBrush}">
				<UniformGrid Rows="1"
							 Margin="0,2,10,0"
							 DockPanel.Dock="Right">
					<Button x:Name="PART_Minimize"
							Chapter10:CustomChromeWindow.NormalImage="WindowDecoration/min_normal.png"
							Chapter10:CustomChromeWindow.HoverImage="WindowDecoration/min_hover.png"
							Chapter10:CustomChromeWindow.PressedImage="WindowDecoration/min_pressed.png"
							Style="{StaticResource {ComponentResourceKey TypeInTargetAssembly=Chapter10:CustomChromeWindow, ResourceId=WindowButtonStyle}}" />
					<Button x:Name="PART_Maximize"
							Chapter10:CustomChromeWindow.NormalImage="WindowDecoration/max_normal.png"
							Chapter10:CustomChromeWindow.HoverImage="WindowDecoration/max_hover.png"
							Chapter10:CustomChromeWindow.PressedImage="WindowDecoration/max_pressed.png"
							Style="{StaticResource {ComponentResourceKey TypeInTargetAssembly=Chapter10:CustomChromeWindow, ResourceId=WindowButtonStyle}}" />
					<Button x:Name="PART_Close"
							Chapter10:CustomChromeWindow.NormalImage="WindowDecoration/close_normal.png"
							Chapter10:CustomChromeWindow.HoverImage="WindowDecoration/close_hover.png"
							Chapter10:CustomChromeWindow.PressedImage="WindowDecoration/close_pressed.png"
							Style="{StaticResource {ComponentResourceKey TypeInTargetAssembly=Chapter10:CustomChromeWindow, ResourceId=WindowButtonStyle}}" />
				</UniformGrid>
				<Image Width="22"
					   Height="22"
					   DockPanel.Dock="Left"
					   Source="{TemplateBinding Icon}"
					   Margin="10,2,2,0" />
				<TextBlock Text="{TemplateBinding Title}"
						   Foreground="LightCyan"
						   VerticalAlignment="Center"
						   FontWeight="Bold" />
			</DockPanel>

			<Border Grid.Row="1"
					BorderThickness="1"
					BorderBrush="#3FFFFFFF"
					Margin="8,0,8,8">
				<ContentPresenter />
			</Border>

		</Grid>

		<ControlTemplate.Triggers>
			<Trigger Property="WindowState"
					 Value="Maximized">
				<Setter Property="Chapter10:CustomChromeWindow.NormalImage"
						Value="WindowDecoration/restore_normal.png"
						TargetName="PART_Maximize" />
				<Setter Property="Chapter10:CustomChromeWindow.HoverImage"
						Value="WindowDecoration/restore_hover.png"
						TargetName="PART_Maximize" />
				<Setter Property="Chapter10:CustomChromeWindow.PressedImage"
						Value="WindowDecoration/restore_pressed.png"
						TargetName="PART_Maximize" />
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
	<Style TargetType="{x:Type Chapter10:CustomChromeWindow}">
		<Setter Property="Template"
				Value="{StaticResource {ComponentResourceKey TypeInTargetAssembly=Chapter10:CustomChromeWindow, ResourceId=WindowTemplate}}" />
	</Style>
</ResourceDictionary>